home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / amos / AMCAFExa.lha / AMCAF_Examples / VecRotWireRubber.AMOS / VecRotWireRubber.amosSourceCode
Encoding:
AMOS Source Code  |  1996-01-17  |  3.3 KB  |  125 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Vec Rot Pos        Turbo Draw
  3. ' *           Amcaf Examples          * Vec Rot Angles     Blitter Clear 
  4. ' * Vector Rotate Wire + Rubber V1.1  * Vec Rot Precalc    =Qsin 
  5. ' *      Written by Chris Hodges      * =Vec Rot X         Set Rain Colour 
  6. ' *                                   * =Vec Rot Y 
  7. ' ************************************* =Vec Rot Z 
  8. '                          
  9. ' Remove the mouse pointer 
  10. Hide 
  11. ' Setup a nice little 2 colours screen with double buffering.  
  12. Screen Open 0,320,256,2,Lowres
  13. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 
  14. Palette 0,$FFF
  15. Double Buffer 
  16. Autoback 0
  17. ' Set up the rainbow, which is used to create the rubber line effect.
  18. Set Rainbow 0,1,128,"","",""
  19. ' Trick to modify the scroll register instead of a colour register.
  20.  Extension_8_1330 0,-63
  21. ' Fill in some sine values.
  22. For A=0 To 127
  23.   B= Extension_8_1106(A*8,7)+7
  24.   Rain(0,A)=B+B*16
  25. Next 
  26. ' Read out, how many coords are used.
  27. Restore COORDS
  28. Read NUMCO
  29. ' Dim one field to keep these coords, and a second for the rotated.
  30. Dim CO(NUMCO,2),RC(NUMCO,1)
  31. ' Now read all coords in.
  32. For A=1 To NUMCO
  33.   Read CO(A,0),CO(A,1),CO(A,2)
  34. Next 
  35. ' Then, get the number of lines the object consists of.
  36. Restore LINES
  37. Read NUMLI
  38. ' Dim a field to hold the startcoord and the endcoord. 
  39. Dim LI(NUMLI,1)
  40. ' Get the datas. 
  41. For A=1 To NUMLI
  42.   Read LI(A,0),LI(A,1)
  43. Next 
  44. ' Set the three angles. Remember that these are non standard angles, 
  45. ' one full rotation is at 1024, not 360! 
  46. AX=0 : AY=512 : AZ=128
  47. ' RP holds the position of the rainbow.
  48. RP=0
  49. Repeat 
  50.   ' Move the rainbow 
  51.   Add RP,1
  52.   Rainbow 0,RP mod 128,Y Hard(-1),259
  53.   ' Clear the screen.
  54.    Extension_8_121C 0,0
  55.   ' While the blitter is working, use the time to calculate the rotations. 
  56.   ' Move and set the angles. 
  57.   Add AX,5
  58.   Add AY,8
  59.   Add AZ,9
  60.    Extension_8_1138 AX,AY,AZ
  61.   ' Calculate the distances by using a sine-function and the three angles. 
  62.   POSX= Extension_8_1106(AX,300)
  63.   POSY= Extension_8_1106(AY,300)
  64.   POSZ= Extension_8_1106(AZ,250)+1000
  65.   ' Set the camera positions.
  66.    Extension_8_1122 POSX,POSY,POSZ
  67.   ' Now it's time to compute the matrix. 
  68.    Extension_8_1152 
  69.   ' So let's rotate all coordinates of the field CO()
  70.   For A=1 To NUMCO
  71.     ' Note: You only have to use the vec rot function with parameters once.
  72.     RC(A,0)= Extension_8_1168(CO(A,0),CO(A,1),CO(A,2))+160
  73.     RC(A,1)= Extension_8_1184 +128
  74.   Next 
  75.   ' It's time to finally get the lines to the screen!
  76.   For A=1 To NUMLI
  77.     ' Starting coordinates pair. 
  78.     C1=LI(A,0)
  79.     ' Ending coordinates pair. 
  80.     C2=LI(A,1)
  81.     ' Get the rotated coordinates
  82.     X1=RC(C1,0) : Y1=RC(C1,1)
  83.     X2=RC(C2,0) : Y2=RC(C2,1)
  84.      Extension_8_1016 X1,Y1 To X2,Y2,1
  85.   Next 
  86.   ' Swap the screens to bring the object to view.
  87.   Screen Swap 
  88.   Wait Vbl 
  89. Until Inkey$=Chr$(27) or Mouse Key<>0
  90. Screen Close 0
  91. Rainbow Del : View : Wait Vbl 
  92. End 
  93. '  1_____2   
  94. ' 5/____/| 
  95. ' | |  |6| 
  96. ' |4|__|_|3  
  97. ' |/___|/
  98. ' 8    7 
  99. COORDS:
  100.   Data 8
  101. ' CUBE 
  102.   Data -100,-100,-100
  103.   Data 100,-100,-100
  104.   Data 100,-100,100
  105.   Data -100,-100,100
  106.   Data -100,100,-100
  107.   Data 100,100,-100
  108.   Data 100,100,100
  109.   Data -100,100,100
  110.  
  111. LINES:
  112.   Data 12
  113. ' CUBE 
  114.   Data 1,2
  115.   Data 2,3
  116.   Data 3,4
  117.   Data 4,1
  118.   Data 5,6
  119.   Data 6,7
  120.   Data 7,8
  121.   Data 8,5
  122.   Data 1,5
  123.   Data 2,6
  124.   Data 3,7
  125.   Data 4,8